﻿<?php

require_once "config.php";

require_once "weixin_info.php"; //å¾®ä¿¡æŽˆæƒèŽ·å–ç”¨æˆ·å¤´åƒç­‰ä¿¡æ?

// print_r($_SESSION['Member_info']);exit;

if (!empty($_GET['way'])) {

    $way = $_GET['way'];

    $id = $_POST['id'];

    if (!empty($id)) {

        $web_sql = $mysql->query("select * from dyspw_weblink where id=" . $id); //è§†é¢‘

        $web_info = $web_sql->fetch_all(MYSQLI_ASSOC);

        if (!empty($web_info)) {

            $web_del = $mysql->query("DELETE FROM dyspw_weblink where id = " . $id);

            if ($web_del) {

                $result['status'] = 'y';

                $result['info'] = '视频删除成功，即将刷新';

                exit(json_encode($result));

            } else {

                $result['status'] = 'n';

                $result['info'] = '视频删除失败';

                exit(json_encode($result));

            }

        } else {

            $result['status'] = 'n';

            $result['info'] = '未查询到该视频信息';

            exit(json_encode($result));

        }

    } else {

        $result['status'] = 'n';

        $result['info'] = '未获取到该视频id';

        exit(json_encode($result));

    }

}

require_once "jssdk.php";

$jssdk = new JSSDK();

$signPackage = $jssdk->GetSignPackage();







$id = $_GET['id'];

$u_id = !empty($id) ? $id : $_SESSION['Member_info'][0]['id'];

if (!empty($u_id)) {

    $sql = $mysql->query("select * from dyspw_member where id=" . $u_id); //è§†é¢‘

    $member_info = $sql->fetch_all(MYSQLI_ASSOC);

} else {

    $member_info = $_SESSION['Member_info'];

}

// print_r($member_info);

$sql = $mysql->query("select * from dyspw_weblink where u_id=" . $u_id . " ORDER BY posttime DESC"); //è§†é¢‘

$rows = $sql->fetch_all(MYSQLI_ASSOC);

// print_r($rows);exit;

if ($member_info[0]['is_vip'] == 3) {

    $explore_sql = $mysql->query("select * from dyspw_weblink where shop_id=" . $u_id . " ORDER BY posttime DESC"); //拍客拍摄作品

    $explore = $explore_sql->fetch_all(MYSQLI_ASSOC);

}

$link_sql = $mysql->query("select * from dyspw_like where uid=" . $u_id . " and state = 1"); //å–œæ¬¢

$like = $link_sql->fetch_all(MYSQLI_ASSOC);

$user_sql = $mysql->query("select * from dyspw_userfavorite where uid=" . $u_id . " and isshow = 1"); //æ”¶è—

$user = $user_sql->fetch_all(MYSQLI_ASSOC);

$foll_sql = $mysql->query("select * from dyspw_follow where fans_id=" . $u_id); //å…³æ³¨

$foll = $foll_sql->fetch_all(MYSQLI_ASSOC);

$fans_sql = $mysql->query("select * from dyspw_follow where u_id=" . $u_id); //ç²‰ä¸

$fans = $fans_sql->fetch_all(MYSQLI_ASSOC);



if ($member_info[0]['is_vip'] == 0 && !empty($member_info[0]['shop_son_id'])) {

    $shop_son_sql = $mysql->query("select * from dyspw_member where id=" . $member_info[0]['shop_son_id']); //è§†é¢‘

    $shop_son = $shop_son_sql->fetch_all(MYSQLI_ASSOC);

    if ($shop_son[0]['is_vip'] == 3) {

        $shop_son_id = $member_info[0]['shop_son_id'];

    }

}

if (!empty($shop_son_id)) {

    $goods_sql = $mysql->query("select * from dyspw_goods where u_id=" . $shop_son_id . " ORDER BY time DESC"); //ç²‰ä¸

    $goods = $goods_sql->fetch_all(MYSQLI_ASSOC);

} else {

    $goods_sql = $mysql->query("select * from dyspw_goods where u_id=" . $u_id . " ORDER BY time DESC"); //ç²‰ä¸

    $goods = $goods_sql->fetch_all(MYSQLI_ASSOC);

}

$user_arr = array();

foreach ($user as $key => $val) {

    $web_sql = $mysql->query("select * from dyspw_weblink where id=" . $val['aid']);

    $array = $web_sql->fetch_all(MYSQLI_ASSOC);

    if (!empty($array)) {

        $user_arr[] = $array[0];

    }

}

// print_r($goods);exit;

$like_count = 0;

foreach ($rows as $key => $val) {

    $web_sql = $mysql->query("select * from dyspw_like where weblinkid=" . $val['id']);

    $array = $web_sql->fetch_all(MYSQLI_ASSOC);

    $like_count = $like_count + count($array);

}

?>

<!doctype html>

<html>



<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">

    <title>个人中心</title>

    <link rel="stylesheet" href="css/core.css">

    <link href="//cdn.bootcss.com/layer/3.0.1/skin/default/layer.css" rel="stylesheet">

    <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>

    <script src="js/jquery.cookie.js" type="text/javascript"></script>

    <!-- <script src="js/layer/layer.js" type="text/javascript"></script> -->

    <script src="//cdn.bootcss.com/layer/3.0.1/layer.min.js"></script>

    <script src="js/dsbridge.js" type="text/javascript"></script>
    <script src="js/app-login.js" type="text/javascript"></script>


    <style media="screen">

        <?php if ($member_info[0]['is_vip'] == 3) { ?>.grls-info-box {

            background: url(images/mem_shop.png) center center no-repeat

        }



        <?php

        } else { ?>.grls-info-box {

            background: url(images/mem_geren.png) center center no-repeat;

        }



        <?php

        } ?>.grls-menu-box ul li.cur div {

            background-image: url("./images/user_menu_bg.png");

        }

    </style>

    <style>

        .talkSpan {

            display: inline-block;

            background: #6594f5;

            float: right;

            color: #FFF;

            font-size: 12px;

            border-radius: 12px;

            display: block;

            line-height: 25px;

            height: 25px;

            width: 62px;

            text-align: center;

        }

    </style>



    <style>

        .roomNumber {

            height: 35px !important;

            line-height: 35px !important;

            border: none;

            border-bottom: 1px solid #777;

        }



        .layui-layer-title,

        .layui-layer-btn .layui-layer-btn0 {

            background: linear-gradient(to bottom, #fb7e76, #ff0202);

            color: #FFF;

        }



        .layui-layer-btn .layui-layer-btn0 {

            border-color: #ff0202

        }



        .layui-layer-page .layui-layer-content {

            padding: 30px 20px;

        }



        #putWindow>div {

            line-height: 35px;

            border-radius: 10px;

            text-align: center;

            color: #000;

            font-size: 16px;

            background: linear-gradient(to bottom, #fb7e76, #ff0202);

            color: #FFF;

            margin: 10px 0;

        }

    </style>

    <script>

        var _hmt = _hmt || [];

        (function() {

            var hm = document.createElement("script");

            hm.src = "https://hm.baidu.com/hm.js?cb5d49b07e0a753dc8ee27ba2c73495d";

            var s = document.getElementsByTagName("script")[0];

            s.parentNode.insertBefore(hm, s);

        })();

    </script>

</head>



<body>

    <section style="padding-bottom:50px;">

        <div class="main" style="width:90%; ">



            <div class="grls-info-box cl" style="padding-bottom:0px;">

                <div class="" style="display: inline-block; width:100%;">

                    <div class="grls-avatar-box">

                        <a href="shop_edit.php"><img src="<?php echo $member_info[0]['avatar'] ?>" /></a>

                    </div>

                    <div class="grls-desc-box" style="position: relative;">

                        <?php if(empty($id)){?><a href="address_setup.php"><img src="images/mem_setup.png" alt="" style="width: 20px;position: absolute;right: 0px;top: 7px;"></a><?php  } ?>

                        <a href="shop_edit.php">

                            <h2 style="<?php if (!empty($id)) {

                                            echo 'background:none';

                                        } ?>"><?php echo $member_info[0]['username'] ?></h2>

                        </a>

                        <p><?php echo $member_info[0]['intro'] ?></p>

                        <div class="btn-box cl">

                            <!-- <a href="#"><img src="images/header-search.png">æŸ¥æ‰¾</a> -->

                            <a href="#" style="float:left;">
                                <?php if ($member_info[0]['is_vip'] == 3) {

                                    echo "商户";

                                } elseif ($member_info[0]['is_vip'] == 2) {

                                    echo "个人";

                                } elseif ($member_info[0]['is_vip'] == 4) {

                                    echo "业务员";

                                } elseif ($member_info[0]['is_vip'] == 1) {

                                    echo "拍客";

                                } else {

                                    echo "游客";

                                } ?>
                            </a>


                            <?php if (empty($id)) { ?>

                                <?php if ($member_info[0]['is_vip'] == 3 || !empty($member_info[0]['shop_son_id'])) { ?>

                                    <a style="float:left; margin-left:6px;" href="javascript:void(0);" onclick="toScan();"><img src="images/sys.png">扫一扫</a>

                                    <span class="talkSpan">聊天室</span>

                                <?php

                                } elseif ($member_info[0]['is_vip'] == 4) { ?>

                                    <a style="float:left; margin-left:6px;" href="personalCenter.php">业务员中心</a>

                                <?php

                                } ?>

                            <?php }else{  ?>
                                <a href="#" style="float:left; margin-left:5px;" onclick="OnReport(<?php echo $id; ?>,'Report');">举报</a>
                                <a href="#" style="float:left; margin-left:5px;" onclick="OnReport(<?php echo $id; ?>,'block');">拉黑</a>
                            <?php }  ?>

                        </div>

                    </div>

                </div>

                <p style="    line-height: 40px;padding-left: 10px;">

                    <span style="margin-right: 10px;font-size: 12px;color: white;"><em><?php echo $like_count; ?></em> 获赞</span>

                    <a href="follow.php<?php if (!empty($id)) {

                                            echo '?id=' . $id;

                                        } ?> ">

                        <span style="margin-right: 10px;font-size: 12px;color: white;"><em><?php echo count($foll); ?></em> 收藏</span>

                        <span style="font-size: 12px;color: white;"><em><?php echo count($fans); ?></em> 粉丝</span>

                    </a>
                    <a href="http://www.shangjinxia.ltd/test/serverProtocol/index.html" style="font-size: 12px;margin-left: 5px;color: #fff;">服务协议 | </a>
                    <a href="http://www.shangjinxia.ltd/test/privacyProtocol/index.html" style="font-size: 12px;color: #fff;">隐私协议</a>

                </p>

            </div>

            <?php if (empty($id)) { ?>

                <div class="grls-menu-box">

                    <ul class="cl">

                        <li class="cur">

                            <div style=""> <a href="https://5p8.fyh5p8.com/xiaochengxu/fenlei.php"><img src="images/icon_fl.png" /></a></div>分类

                        </li>

                        <li><a href="wallet.php">

                                <div><img src="images/icon_qb.png" /></div>钱包

                            </a></li>

<!--                        <li>-->

<!--                            <div><img src="images/icon_kf.png" /></div>客服-->

<!--                        </li>-->

                        <?php if ($member_info[0]['is_vip'] == 3) { ?>

                            <li><a href="shop_edit.php">

                                    <div><img src="images/icon_sz.png" /></div>商铺设置

                                </a></li>

                        <?php

                        } else { ?>

                            <li><a href="shop_edit.php">

                                    <div><img src="images/icon_sz.png" /></div>用户设置

                                </a></li>

                        <?php

                        } ?>

                        <li>

                            <!-- <div><a href="http://console.nuoyun.tv/Mobile/Index/index"><img src="images/icon_bf.png" /></a></div>直播 -->

                        </li>

                    </ul>

                </div>

            <?php

            } ?>



            <div class="grls-banner-box" style="    margin-top: 10px;">

                <a href="recharge.php"><img src="images/grls_banner.png" /></a>

            </div>



            <div class="grls-spjx-box">

                <?php if ($member_info[0]['is_vip'] == 3 || $member_info[0]['is_vip'] == 2) { ?>

                    <h2 class="cl">

                        <font>商品精选</font>

                        <p>Product selection</p>

                        <?php if (empty($id)) { ?><a href="goods_edit.php" style="    display: inline-block;float: right;font-size: 14px;border: 1px solid #C79400;line-height: 30px;padding: 0px 10px;border-radius: 6px;background: #C79400;color: #fff;margin-top: 5px;">添加商品</a>

                        <?php

                        } ?>

                    </h2>

                    <div class="spjx-box">

                        <ul class="cl">

                            <?php if (!empty($goods)) {

                                foreach ($goods as $key => $val) {

                                    if ($key < 4) { ?>

                                        <li><a href="goods_info.php?id=<?php echo $val['id']; ?>"><img src="<?php echo $val['img'] ?>" /><span style="text-align: left;float: left;">原价:<?php echo $val['money'] ?><br/ ><em style="font-size: 14px;color: red;">团购价:<?php echo $val['group_money'] ?></em></span>

                                                <p class="title"><?php echo $val['title'] ?></p>

                                                <p><?php echo $val['details']; ?></p>

                                            </a></li>

                                <?php

                                    }

                                } ?>

                                <?php if ($member_info[0]['is_vip'] == 3 || $member_info[0]['is_vip'] == 2) { ?>

                                    <?php if (empty($id)) { ?><li style="padding: 0px;"><a href="goods_edit.php" style="    display: block;width: 100px;"><img src="images/add_goods.png" alt=""></a></li><?php

                                                                                                                                                                                                        } ?>

                            <?php

                                }

                            } ?>

                        </ul>

                    </div>

            </div>

        <?php

                } ?>



<!--            --><?php //if ($member_info[0]['is_vip'] == 3 || $member_info[0]['is_vip'] == 2) { ?>

            <style>

                .navigationBox{background: #3f79f3;border-radius: 5px;color: #fff;padding:15px 8px;height: auto;overflow: hidden}

                .navigationBox img{float: left;width: 20px;}

                .navigationBox p{float: left;margin-left: 5px;height: auto;overflow: hidden}

                .navigationBox a{float:right;height: auto;overflow: hidden;background: #fff;color: #000;border-radius: 5px;padding: 3px 10px;margin-top:3px}

            </style>

            <div id='container1' style="display:none"></div>

            <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=d021bae86db1d54dddc4071a5123749c&plugin=AMap.Geocoder"></script>



            <script type="text/javascript">

                var ipBool=false;

                var lng,lat;

                AMap.plugin('AMap.Geolocation', function() {

                    var geolocation = new AMap.Geolocation({

                        enableHighAccuracy: true,

                        timeout: 10000,

                        buttonOffset: new AMap.Pixel(10, 20),

                        zoomToAccuracy: true,

                        buttonPosition: 'RB'

                    });

                    geolocation.getCurrentPosition();

                    AMap.event.addListener(geolocation, 'complete', onComplete);

                    AMap.event.addListener(geolocation, 'error', onError);

                    function onComplete (result) {

                        lng=result.position.getLng();

                        lat=result.position.getLat();

                        <?php if($member_info[0]['shop_lng'] && $member_info[0]['shop_lat']){?>

                        ipBool=true;

                        var p1 =  new AMap.LngLat(lng, lat);

                        var p2 =  new AMap.LngLat(<?php echo $member_info[0]['shop_lng']?>, <?php echo  $member_info[0]['shop_lat']?>);

                        var distance = Math.round(p1.distance(p2));

                        $(".navigationBox p font").html(distance);

                        <?php }?>

                    }



                    function onError (data) {

                        // alert(JSON.stringify(data));

                    }

                });



                function navigation() {

                    if(window.navigator.userAgent == 'AndroidNative'){

                        dsBridge.call("mapSite", {lng: "<?php echo $member_info[0]['shop_lng']?>", lat: "<?php echo $member_info[0]['shop_lat']?>", name: "<?php echo $member_info[0]['shop_add']?>"});

                    } else if (window.navigator.userAgent == 'IosNative') {

                        dsBridge.call("mapSite", {lng: "<?php echo $member_info[0]['shop_lng']?>", lat: "<?php echo $member_info[0]['shop_lat']?>", name: "<?php echo $member_info[0]['shop_add']?>"});

                    } else {

                        if(ipBool){

                            window.location.href="http://uri.amap.com/navigation?from="+lng+","+lat+"&to=<?php echo $member_info[0]['shop_lng']?>,<?php echo  $member_info[0]['shop_lat']?>&mode=car&name='<?php echo $member_info[0]['shop_add']?>'&src=nyx_super";

                        }else {

                            <?php if($member_info[0]['shop_lng'] && $member_info[0]['shop_lat']){?>

                                alert('定位信息获取失败，请查看GPS是否开启');

                            <?php }else{?>

                                alert('商家位置信息未完善');

                            <?php }?>

                        }

                    }

                }

            </script>



            <div class="navigationBox">

                <img src="./images/dingwei.png">

                <p><?php echo $member_info[0]['shop_add']?><br>

                    距您<font>10000</font>米

                </p>

                <a onclick="navigation()">导航</a>

            </div>

<!--            --><?php // } ?>





        <div class="video-nav-box grls cl">

            <?php if ($member_info[0]['is_vip'] == 3 || !empty($shop_son_id)) { ?>

                <style media="screen">

                    .video-nav-box.grls a {

                        width: 25% !important;

                    }

                </style>

                <a href="mem_goods.php<?php if (!empty($id)) {

                                            echo '?id=' . $id;

                                        } ?>">商品 <?php echo count($goods); ?></a>

            <?php

            } ?>

            <a href="member.php<?php if (!empty($id)) {

                                    echo '?id=' . $id;

                                } ?>   " class="cur">作品 <?php echo count($rows); ?> </a>

            <a href="mem_collection.php<?php if (!empty($id)) {

                                            echo '?id=' . $id;

                                        } ?>">收藏<?php echo count($user_arr); ?></a>

            <a href="mem_like.php<?php if (!empty($id)) {

                                        echo '?id=' . $id;

                                    } ?>">喜欢 <?php echo count($like); ?></a>

        </div>



        <div class="video-box grls" id="Collection">

            <ul class="cl">

                <?php if (!empty($explore)) { ?>

                    <?php foreach ($explore as $k => $v) { ?>

                        <li>

                            <a href="content.php?id=<?php echo $v['id']; ?>">

                                <div class="" style="position: relative;">

                                    <img src="<?php echo $v['linkurl'] . "?vframe/jpg/offset/1/w/368/h/640/rotate/auto"; ?>" class="">

                                </div>

                                <h2 style="font-size: 11px;line-height: 30px;"><?php echo $v['webnote'] ?></h2>

                                <div class="video-desc">

                                    <div class="fl"><?php echo $v['webname'] ?></div><em><?php echo $v['hits'] ?></em>

                                </div>

                            </a>

                        </li>

                    <?php

                    } ?>

                <?php

                } ?>



                <?php foreach ($rows as $k => $v) { ?>

                    <li class="video_list">

                        <a href="content.php?id=<?php echo $v['id']; ?>">

                            <div style="position: relative;">

                                <p style="position: absolute;top: 5px;float:right;width:100%;">

                                    <span class="del_video" web_id="<?php echo $v['id']; ?>"><?php if (empty($id)) {  echo '<img style="width:30px; float:right;" src="images/delite.png" alt="">';  } ?></span>

                                </p>

                                <img src="<?php echo $v['linkurl'] . "?vframe/jpg/offset/1/w/368/h/640/rotate/auto"; ?>" class="">

                            </div>

                            <h2 style="font-size: 11px;line-height: 30px;"><?php echo $v['webnote'] ?></h2>

                            <div class="video-desc">

                                <div class="fl"><?php echo $v['webname'] ?></div><em><?php echo $v['hits'] ?></em>

                            </div>

                        </a>

                    </li>

                <?php

                } ?>

            </ul>







        </div>

        </div>

        <?php if (!empty($id) && $member_info[0]['is_vip'] == '3') { ?>

            <div class="" style="relative">

                <a href="baishe.php?shop_id=<?php echo $member_info[0]['id']; ?>" style="display: inline-block;background: #3f79f3;position: fixed;bottom: 30px;width: 100px;line-height: 35px;text-align: center;border-radius: 20px;color: #fff;font-size: 12px;left: 50%;transform: translateX(-50%);letter-spacing: 1px;">探店领现金</a>

            </div>

        <?php

        } ?>

    </section>

    <?php if (empty($id)) { ?>

        <footer style="background-color:#FFF;">

            <ul class="cl">

                <li><a href="index.php">首页</a></li>

                <li><a href="fenlei.php">分类</a></li>

                <li><a href="baishe.php">拍</a></li>

                <li><a href="shopping.php">商城</a></li>

                <li><a href="member.php">我</a></li>

            </ul>

        </footer>

    <?php

    } ?>



    <div id="putWindow" style="display: none;">

        <!-- <input type="text" name="roomInput" placeholder="请输入房间号" class="roomNumber"> -->

        <div onclick="joinRTCRoom(0)">语音通话</div>

        <div onclick="joinRTCRoom(1)">视频通话</div>

    </div>



    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

    <script type="text/javascript">

        var _shopid = <?php echo $_SESSION['Member_info'][0]['id'] ?>;

        $(function() {

            $(".del_video").click(function() {

                if (confirm("确认删除此视频?")) {

                    $(this).parent().parent().parent().removeAttr('href');

                    var id = $(this).attr('web_id');

                    $.ajax({

                        url: 'member.php?way=delete',

                        type: "post",

                        data: {

                            'id': id

                        },

                        dataType: 'json',

                        success: function(res) {

                            console.log(res);

                            if (res.status == 'y') {

                                layer.open({

                                    content: res.info,

                                    skin: 'msg',

                                    time: 2

                                });

                                location.href = "https://5p8.fyh5p8.com/xiaochengxu/member.php";

                            } else {

                                layer.open({

                                    content: res.info,

                                    skin: 'msg',

                                    time: 2

                                });

                            }

                        }

                    })

                }

            })



            $(".talkSpan").click(function() {

                layer.open({

                    type: 1,

                    title: '通话方式',

                    // area: '300px',

                    // area: ['200px','150px'],

                    shade: 0.8,

                    shadeClose: true,

                    // skin: 'yourclass',

                    content: $('#putWindow'),

                    // btn: ['确定', '取消'], //按钮组

                    // yes: function(index){

                    //     layer.close(index);

                    //     joinRTCRoom();

                    // }

                });

            })



            $(".grls-menu-box li").click(function() {

                $(this).addClass("cur").siblings().removeClass("cur");

            });



            wx.config({

                debug: false,

                appId: '<?php echo $signPackage["appId"]; ?>',

                timestamp: <?php echo $signPackage["timestamp"]; ?>,

                nonceStr: '<?php echo $signPackage["nonceStr"]; ?>',

                signature: '<?php echo $signPackage["signature"]; ?>',

                jsApiList: [

                    'checkJsApi',

                    'scanQRCode',

                ]

            });

            wx.error(function(res) {

                alert("出错了：" + res.errMsg); //这个地方的好处就是wx.config配置错误，会弹出窗口哪里错误，然后根据微信文档查询即可。

            });

        });

        window.scanQrCode = function(str){

            if (str) {

                $.ajax({

                    url: str,

                    dataType: 'json',

                    type:'get',

                    data:{"shop_id":_shopid},

                    success:function(res){

                        if(res.code == 200){

                            alert(res.msg);

                            layer.open({content: res.msg,skin: 'msg',time: 3 });

                        }else if (res.code == 400) {

                            alert(res.msg);

                            layer.open({content: res.msg,skin: 'msg',time: 3 });

                        }

                    },

                    error:function(){

                        //请求出错处理

                    }

                })

            }

        }
        /*举报拉黑*/
        function OnReport(shop_id,type){
            var uid = '<?php echo $_SESSION['Member_info'][0]['id']; ?>';
            $.ajax({
                url: 'mem_Report_ajax.php',
                dataType: 'json',
                type:'post',
                data:{"shop_id":shop_id, 'uid':uid,'type':type},
                success:function(res){
                    if(res.state == 'y'){
                        alert(res.info);
                    }else if (res.state == 'n') {
                        alert(res.info);
                    }else{
                        layer.open({content: '请联系管理员',skin: 'msg',time: 3 });
                    }
                }
            });
        }
        function toScan() {

            if(window.navigator.userAgent == 'AndroidNative'){

                dsBridge.call("openScanQrCodeActivity","openScanQrCodeActivity");

            } else if (window.navigator.userAgent == 'IosNative') {

                dsBridge.call("openScanQrCodeActivity","openScanQrCodeActivity");

            } else {
                wx.ready(function() {

                    wx.checkJsApi({

                        jsApiList: ['scanQRCode'],

                        success: function(res) {

                            console.log('扫一扫：', res)

                        }

                    });



                    wx.scanQRCode({

                        needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，

                        scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有

                        success: function(res) {

                            var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果

                            $.ajax({

                                url: result,

                                dataType: 'json',

                                type:'get',

                                data:{"shop_id":_shopid},

                                success:function(res){

                                    if(res.code == 200){

                                        alert(res.msg);

                                        layer.open({content: res.msg,skin: 'msg',time: 3 });

                                    }else if (res.code == 400) {

                                        alert(res.msg);

                                        layer.open({content: res.msg,skin: 'msg',time: 3 });

                                    }

                                },

                                error:function(){

                                    //请求出错处理

                                }

                            })

                        },

                        error: function(res) {

                            alert(res)

                        }

                    });

                });
            }
        }





        function joinRTCRoom(type) {

            var roomNumber = '5p' + '<?php echo $_SESSION['Member_info'][0]['id'] ?>'; //房间号

            var userid = '5p8' + '<?php echo $_SESSION['Member_info'][0]['id'] ?>'; //用户



            if (type === 1 && window.navigator.userAgent == 'AndroidNative') {

                // javascript: android.openRTCActivity(type, '<?php echo $_SESSION['Member_info'][0]['id'] ?>');

                dsBridge.call("openRTCActivity", {type: type, shopId: '<?php echo $rows[0]['u_id'] ?>'});

            } else if (window.navigator.userAgent == 'IosNative') {

                dsBridge.call("openRTCActivity", {type: type, shopId: '<?php echo $rows[0]['u_id'] ?>'});

                // window.webkit.messageHandlers.openRTCActivity.postMessage({

                //     type: type,

                //     id: '<?php echo $_SESSION['Member_info'][0]['id'] ?>',

                // });

            }else {

                //提交接口

                $.ajax({

                    url: 'qiniu_ajax.php', //后台补充接口

                    type: "post",

                    data: {

                        'roomNumber': roomNumber,

                        'userid': userid

                    },

                    dataType: 'json',

                    timeout: 10000,

                    beforeSend: function() {

                        // lid = layer.open({

                        //     type: 2,

                        //     content: '提交中...',

                        //     shadeClose: false

                        // });

                    },

                    success: function(res) {

                        console.log(res, '房间提交返回');

                        if (res.status == 'y') {

                            var roomToken = res.data; //获取到roomToken

                            setTimeout(() => {

                                window.location = 'qnRTC.html?roomToken=' + roomToken + '&type=' + type;

                            }, 1000);

                        } else {

                            layer.open({

                                content: res.info,

                                skin: 'msg',

                                time: 2

                            });

                        }





                    },

                    complete: function() {

                        //layer.close(lid);

                    },

                    error: function(XMLHttpRequest, textStatus) {

                        layer.close(lid);

                        if ('timeout' == textStatus) {

                            alert('请求接口超时！');

                        } else {

                            alert('系统错误，请刷新重试！')

                        }

                    }

                });

            }

        }

    </script>

</body>



</html>
